﻿using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.ApplicationPages;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint.Utilities;
using System.Web.UI.WebControls;

namespace SharePointHNSC.ApplicationPages
{
    public partial class HostNameSiteCreated : DialogAdminPageBase
    {
        protected HyperLink LinkRootWeb;

        protected Literal desc;

        protected override string PageToRedirectOnMissingPageParameter
        {
            get
            {
                return "/_admin/SharePointHNSC/CreateHostNamedSite.aspx";
            }
        }

        public override string PageToRedirectOnOK
        {
            get
            {
                return "/applications.aspx";
            }
        }

        protected override string[] RequiredPageParameters
        {
            get
            {
                return new string[] { "SiteId" };
            }
        }

        protected void OkButtonClick(object sender, EventArgs e)
        {
            base.EndOperation();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                string item = base.Request.QueryString["SiteId"];
                SPUrlZone zone = SPControl.GetContextSite(this.Context).Zone;
                using (SPSite sPSite = new SPSite(new Guid(item), zone))
                {
                    string url = sPSite.Url;
                    this.LinkRootWeb.Text = SPHttpUtility.HtmlEncode(url);
                    this.LinkRootWeb.NavigateUrl = SPHttpUtility.UrlPathEncode(url, true);
                }
                this.DataBind();
            }
        }
    }
}
